package com.mc.music_web.controller;

import com.github.pagehelper.PageInfo;
import com.mc.music_web.entity.Song;
import com.mc.music_web.services.SongVoService;
import com.mc.music_web.vo.SongVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.List;

@Controller
public class SongController {

    @Autowired
    private SongVoService songVoService;


    @RequestMapping("/admin/lastSong")
    public  String goSong(){

        return "/admin/song";
    }

    @RequestMapping("/admin/songList")
    @ResponseBody
    public List songList(){
        List<SongVo> list=songVoService.selectSongVo();
        return list;
    }


    @RequestMapping("/admin/goSongUpdate")
    @ResponseBody
    public Song updateSong(Integer songId) {

        Song song = songVoService.selectBySong(songId);

        return song;
    }


    @RequestMapping("/admin/doSongUpdate")
    @ResponseBody
    public Song doUpdateSong(Song song) {

        songVoService.updateSong(song);
        return song;
    }


 /*   @RequestMapping("/admin/goSongLimit")
    @ResponseBody
    public PageInfo selectSongLimit(int pageNum, HttpSession session) {
        PageInfo<Song> pageInfosO = songVoService.selectSongLimit(pageNum);
        session.setAttribute("songSession",pageInfosO);
        return pageInfosO;
    }*/


    @RequestMapping("/admin/songDel")
    @ResponseBody
    public int delSong(Integer songId) {
        int result = songVoService.deleteSong(songId);
        return result;
    }



    @RequestMapping("/admin/addSongs")
    @ResponseBody
    public Integer addSinger(Song song){

        Integer i = songVoService.insertSong(song);
        return i;
    }

    @RequestMapping("/admin/adminBySong")
    @ResponseBody
    public  List  selectBySong(String keyword){
        List<SongVo> list=songVoService.selectByChooseSong(keyword);
        return list;
    }
}
